﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Stanza.Silverlight.Controls;
using Stanza.Silverlight.Browser;

namespace Demo
{
    public partial class AutoSizeDemo : AutoSizeUserControl
    {
        public AutoSizeDemo()
        {
            InitializeComponent();

            Loaded += delegate( object loadSender, RoutedEventArgs loadArgs ) {
                FrameworkElement root = Application.Current.RootVisual as FrameworkElement;
                if( root != null )
                    root.SizeChanged += Page_SizeChanged;
            };

            fullScreenButton.Click += delegate( object sender, RoutedEventArgs e ) {
                Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
            };
        }

        void Page_SizeChanged( object sender, SizeChangedEventArgs e )
        {
            controlWidthBox.Text = e.NewSize.Width.ToString();
            controlHeightBox.Text = e.NewSize.Height.ToString();
            browserWidthBox.Text = HtmlTools.BrowserWindowWidth.ToString();
            browserHeightBox.Text = HtmlTools.BrowserWindowHeight.ToString();
        }
    }
}
